<?php

class Model_User_resource {

    protected $resource_id;
    protected $user_id;
    protected $name;
    protected $extension;
    protected $content_type;
    protected $path;

    public function __construct(array $options = null) {
        if (is_array($options)) {
            $this->setOptions($options);
        }
    }

    public function __set($name, $value) {
        $method = 'set' . ucfirst($name);
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Invalid content property');
        }
        $this->$method($value);
    }

    public function __get($name) {
        $method = 'get' . ucfirst($name);
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Invalid content property');
        } return $this->$method();
    }

    public function setOptions(array $options) {
        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
    }

    public function setResource_id($value) {
        $this->resource_id = $value;
    }

    public function getResource_id() {
        return $this->resource_id;
    }

    public function setUser_id($value) {
        $this->user_id = $value;
    }

    public function getUser_id() {
        return $this->user_id;
    }

    public function setName($value) {
        $this->name = $value;
    }

    public function getName() {
        return $this->name;
    }

    public function setExtension($value) {
        $this->extension = $value;
    }

    public function getExtension() {
        return $this->extension;
    }

    public function setContent_type($value) {
        $this->content_type = $value;
    }

    public function getContent_type() {
        return $this->content_type;
    }

    public function setPath($value) {
        $this->path = $value;
    }

    public function getPath() {
        return $this->path;
    }

    public function toArray() {
        return get_object_vars($this);
    }

}

